package homework.morning;

import java.util.*;

/*
    有一个文件内容为
    1.张三，26,5000
    1.李四，26,5000
    1.王五，26,5000
    1.李四，26,5000
    1.张三，26,5000
    1.张三，26,5000
    将文件中人名出现的次数按从高往低排序
 */
public class compare {
    public static void main(String[] args) {
        Collection<String> list = new ArrayList<>();
        list.add("张三,26,5000");
        list.add("李四,26,5000");
        list.add("王五,26,5000");
        list.add("李四,26,5000");
        list.add("张三,26,5000");
        list.add("张三,26,5000");
        System.out.println(list);
        Map<String, Integer> map = new HashMap<>();
        int a = 0, b = 0, c = 0;
        for (String s : list) {
            if (s.contains("张三")) {
                a++;
                map.put("张三", a);
            }
            if (s.contains("李四")) {
                b++;
                map.put("李四", b);
            }
            if (s.contains("王五")) {
                c++;
                map.put("王五", c);
            }
        }
//        Set<Map.Entry<String,Integer>> entrySet = map.entrySet();
//        for(Map.Entry<String,Integer> e:entrySet){
//            System.out.println("人名："+e.getKey()+",次数："+e.getValue());
//        }


    }
}
